﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CLFramework.Infrastructure;

namespace CLFramework.Infrastructure.Validation
{
    public abstract class ValidatorBase<T>
    {
        protected ValidatorBase()
        {
        }

        public abstract ValidationState Validate(T entity);

        protected ValidationError CreateValidationError(object value, string validationKey
            , string validationMessageKey, string validationMessage, params object[] validationMessageParameters)
        {
            if (validationMessageParameters != null && validationMessageParameters.Length > 0)
                validationMessage = string.Format(validationMessage, validationMessageParameters);

            return new ValidationError(
                validationKey,
                value,
                new InvalidOperationException(validationMessage)
                );
        }

    }

}
